﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using HashFoo.Rest.Server;
using HashFoo.Rest.ServerTests.FakeHttpStack;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace HashFoo.Rest.ServerTests
{
    [TestClass]
    public class HttpBasicAuthModuleTests
    {
        [TestMethod]
        public void can_create_module_from_default_dependencies()
        {
            var module = new HttpBasicAuthModule();

            Assert.IsNotNull(module);
            Assert.IsNotNull(module.MembershipProvider);
        }

        [TestMethod]
        public void can_create_module_with_injected_membership_provider()
        {
            DependencyResolver.SetResolver(
                t => new FakeHttpStack.FakeMembershipProvider(),
                t => new[] { new FakeHttpStack.FakeMembershipProvider() });

            var module = new HttpBasicAuthModule();
            
            Assert.IsNotNull(module);
            Assert.IsNotNull(module.MembershipProvider);
            Assert.AreEqual(typeof(FakeMembershipProvider), module.MembershipProvider.GetType());

        }
    }
}
